def fall(inntak):
	hjalp = "ABCDEFGHI"
	strengir = []
	strengir2 = []
	for x in range(inntak):
		for y in range(inntak):
			strengir.append(hjalp[x] + str(y))
		
	for x in range(len(strengir)):
		if strengir[x][0] != hjalp[int(strengir[x][1])]:
			strengir2.append(x)
			
	lausn = len(strengir)
	while len(strengir) != 0:
		for x in range(1, len(strengir)):
			if strengir[x][0] == strengir[0][0] or strengir[x][1] == strengir[0][1]:
				strengir.pop(x)
				
		strengir.pop(0)
		if len(strengir) != 0:
			lausn *= len(strengir)
			
	return lausn
	
	
	
profanir = int(input())

tilvik = []
for x in range(profanir):
	tala = int(input())
	tilvik.append(tala)
	print(fall(tala))
